﻿<%@ Page Title="" Language="C#" MasterPageFile="~/usercate/usercate.master" AutoEventWireup="true" CodeBehind="ChatSetup.aspx.cs" Inherits="chatblog.usercate.ChatSetup" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeaderContentPlaceHolder" runat="server">
    <style type ="text/css" >
.legendStyle
{
  padding :2px 2px 2px 2px;   
}
fieldset
{
   padding :5px 5px 5px 5px;  
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">
    <fieldset id ="PersonChatRoom">
        <legend>私人聊天室
        </legend>
        <table style =" width :100%; padding-left :20px">
            <tr>
                <td style =" width :10%;">
                    状态：
                </td>
                <td style =" width :10%;">
                    <a id="StatusAnchorss">在线</a>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td style =" width :10%;">
                </td>
                <td style =" width :10%;">
                </td>
                <td>
                    <input  type ="button" id="ForceButton" value="强制下线" onclick ="chatblog.usercate.ChatSetup.ForceToUnLine();initPersonal();redirectUrl();"/>
                    
                    <a  target ="_blank" href ="../login/password.aspx">修改密码</a>
                </td>
            </tr>
        </table>
    </fieldset>
    <fieldset id ="CommonChatRoom">
        <legend>公共聊天室
        </legend>
        <div style =" padding-left :20px; padding-top :5px; padding-bottom :10px;">
            <a id="CommonChatTipAnchor">您没有打开公共聊天室！</a><br />
            <div id="OnlineChatRoomList" style =" width:100%; background-color :lightBlue">   
            </div>
            <div>                  
                <input id="SelectAllButton" value="全选" type ="button" onclick ="selectAll();" />  
                <input value="反选" id="SelectOtherButton" type ="button" onclick ="selectOthers();" />
                <input value="强制下线"  id="ForceUnlineCommonChatButton" type ="button"  onclick ="commonChatForceUnline();"/>
            </div>
        </div>
    </fieldset>
    <br />
    <input  type ="button"  value ="刷新" onclick =" flushStatus();"/>
    <script type ="text/javascript" >
        function getQueryString(queryName) {
            var queryValue = "";
            var queryFound = false;
            if (window.location.search != "") {
                var search = window.location.search;
                var i = 0;
                while (i <= search.length) {
                    start = i;
                    end = start + queryName.length;
                    if (search.substring(start, end) == queryName) {
                        queryFound = true;
                        break;
                    }
                    i++;
                }
                if (queryFound) {
                    start = end + 1;
                    end = search.indexOf("&", start);
                    if (end < start)
                        end = search.length;
                    var getvalue = search.substring(start, end);
                    return unescape(getvalue);
                }
            }
            return queryValue;
        }
        
        function initPersonal() {
            document.getElementById('StatusAnchorss').innerHTML = chatblog.usercate.ChatSetup.GetPersonChatRoomStatus().value;
            
            //document.getElementById('ForceButton').style.display = (document.getElementById('StatusAnchorss').innerHTML == "在线") ? "block" : "none";
        }
        var redirectArray = ["", "../usercate/chRoom.aspx", ""];
        function redirectUrl() {
            var redirect = getQueryString("redirect");
            if (redirect != "" && parseInt(redirect)!=null) {
                //if (confirm("是否跳转到刚才的页面？") == true) 
                {
                    window.location.href = redirectArray[parseInt(redirect )];
                }
            }
        }
        function initCommon() {
            var html = chatblog.usercate.ChatSetup.GetCommonChatListHTML().value;
//            document.getElementById('SelectAllButton').style.display = (html == "") ? "none" : "display";
//            document.getElementById('SelectOtherButton').style.display = (html == "") ? "none" : "display";
//            document.getElementById('ForceUnlineCommonChatButton').style.display = (html == "") ? "none" : "display";
            document.getElementById('CommonChatTipAnchor').innerHTML = (html == "") ? "您没有打开公共聊天室！" : "在线的公共聊天室：";
            document.getElementById('OnlineChatRoomList').innerHTML = html;
        }
        function selectAll() {
            var allChatRoomCheckBox = document.getElementById('OnlineChatRoomList').getElementsByTagName ( 'input');
            if (allChatRoomCheckBox.length != null && allChatRoomCheckBox.length > 0) {
                for (var i = 0; i < allChatRoomCheckBox.length; i++) {
                    if (allChatRoomCheckBox[i].type == "checkbox")
                        allChatRoomCheckBox[i].checked = true;
                } 
            }
        }
        function selectOthers() {
            var allChatRoomCheckBox = document.getElementById('OnlineChatRoomList').getElementsByTagName('input');
            if (allChatRoomCheckBox.length != null && allChatRoomCheckBox.length > 0) {
                for (var i = 0; i < allChatRoomCheckBox.length; i++) {
                    if (allChatRoomCheckBox[i].type == "checkbox")
                        allChatRoomCheckBox[i].checked = (allChatRoomCheckBox[i].checked == true) ? false : true;
                } 
            }
        }
        function commonChatForceUnline() {
            var allChatRoomCheckBox = document.getElementById('OnlineChatRoomList').getElementsByTagName('input');
            if (allChatRoomCheckBox.length != null && allChatRoomCheckBox.length > 0) {
                for (var i = 0; i < allChatRoomCheckBox.length; i++) {
                    if (allChatRoomCheckBox[i].type == "checkbox" && allChatRoomCheckBox[i].checked == true) {
                        var roomID = allChatRoomCheckBox[i].id;
                        chatblog.usercate.ChatSetup.ForceCommonChatRoomUnline(roomID);
                        alert("强制下线成功！");
                    }
                } 
            }
        }
        function flushStatus() {
            initPersonal();
            initCommon();
        }
        flushStatus();
        
    </script>
</asp:Content>
